package com.myopen.controller.cms;

import java.util.Date;
import java.util.Random;

import com.jfinal.core.ActionKey;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.myopen.base.BaseController;
import com.myopen.base.BaseVo;
import com.myopen.kit.DateKit;
import com.myopen.kit.UUIDKit;

public class ShopController extends BaseController{

    @ActionKey("/shop/product")
	public void order() {
        render("/product.html");
	}

    @ActionKey("/shop/pay")
	public void creat_order() {
		
		String orderNumber=DateKit.format(new Date(), "yyyyMMddHHmmss"+new Random().nextInt(2));
		Record order=new Record();
		order.set("id", UUIDKit.getUUID());
		order.set("removed","0");
		order.set("createTime",new Date());
		order.set("updateTime", new Date());
		order.set("number", orderNumber);
		//TODO价格这里不安全
		//order.set("amount", Double.parseDouble(params.getStr("totalPrice")));
		order.set("amount", 0.01D);
		Db.save("t_shop_order", order);

		setAttr("vo", order);
        render("pay.html");
	}

}